package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * 消费死信队列中的消息
 */
public class Consumer02 {



    // 死信队列的名称
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {


        Channel channel = RabbitMqUtils.getChannel();

        System.out.println("Consumer02等待接受消息");


        DeliverCallback deliverCallback = (consumerTage, message) -> {
            System.out.println("Consumer02接收到的消息是："+new String(message.getBody(),"utf-8"));
        };

        channel.basicConsume(DEAD_QUEUE, true, deliverCallback,consumer->{

        });
    }
}
